<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">
			*{
				margin: 0;
				padding: 0;
			}
			html, body{
				text-align: center;
			}
			#box{
				position: relative;
				margin: 50px auto 20px;
				height: 220px;
				width: 329px;
				border: 4px solid #ccc;
				overflow: hidden;
			}
			#box li{
				list-style: none;
				float: left;
			}
			#box ul{
				
				height: 100%;
				position: absolute;
				top: 0;
				left: 0;
			}
		</style>
	</head>
	<body>
		<div id="box">
			<ul>
				<li><a href=""><img src="img1217/a.jpg"/></a></li>
				<li><a href=""><img src="img1217/b.jpg"/></a></li>
				<li><a href=""><img src="img1217/c.jpg"/></a></li>
				<li><a href=""><img src="img1217/d.jpg"/></a></li>
				<li><a href=""><img src="img1217/e.jpg"/></a></li>
			</ul>
		</div>
		<button>上一张</button>
		<button>下一张</button>
		<script src="js1217/easingFunction.js"></script>
		<script src="js1217/myAnimate.js"></script>
		<script type="text/javascript">
			window.onload = function(){
				var slider = document.getElementById('box').getElementsByTagName('ul')[0];
				var arrLi = slider.getElementsByTagName('li');
				var singleWidth = arrLi[0].offsetWidth;
				slider.style.width = singleWidth * arrLi.length + 'px';
				var arrBtn = document.getElementsByTagName('button');
				var iCurrImg = 0;
				
				function getZuoBiao(i){
					return -1 * singleWidth * i;
				}
				arrBtn[0].onclick = function(){
					if (iCurrImg <= 0) {
						return;
					}
					iCurrImg--;
					var begin = getZuoBiao(iCurrImg + 1);
					var end = getZuoBiao(iCurrImg );
					myAnimate(slider,'left','px',begin,end,600,easeInQuad);
				}
				
				
				arrBtn[1].onclick = function(){
					if (iCurrImg >= arrLi.length - 1) {
						return;
					}
					iCurrImg++;
					var begin = getZuoBiao(iCurrImg - 1);
					var end = getZuoBiao(iCurrImg);
					myAnimate(slider,'left','px',begin,end,600,easeInQuad);
				}
			}
			
		</script>
	</body>
</html>
